using SkaldRogueLike.Main.CellContent.Items;
using SkaldRogueLike.Main.Common;
using SkaldRogueLike.Main.Constants;
using SkaldRogueLike.Main.Constants.Enumerations;

namespace SkaldRogueLike.Main.CellContent.ContentFactories
{
    public class ItemFactory : IGameFactory
    {
        private const int ItemCount = 5;

        public int CurrentNumber { get; private set; }
        public int Uniquiness { get; set; }

        public ItemFactory(int uniquiness)
        {
            Uniquiness = uniquiness;
            CurrentNumber = StaticRandom.Next(ItemCount);
        }

        public CellContent Create()
        {
            CurrentNumber = Uniquiness > StaticRandom.Next(100)
                                ? StaticRandom.NextNotEqualToOld(0, ItemCount, CurrentNumber)
                                : CurrentNumber;
            return GenerateItem(CurrentNumber);
        }

        private static Item GenerateItem(int i)
        {
            switch (i)
            {
                case 0:
                    return new Item("Iron sword", 5, Bonus.Att, "!", Colors.Gray, 
                                    "Old sword made of iron");
                case 1:
                    return new Item("Round shield", 10, Bonus.Def, "0", Colors.Red, 
                                    "Viking shield upholstered in metal");
                case 2:
                    return new Item("Blue potion", -5, Bonus.HP, "&", Colors.Blue, 
                                    "Bottle with liquid.");
                case 3:
                    return new Item("Black potion", 5, Bonus.HP, "&", Colors.Black, "Bottle with liquid.");
                case 4:
                    return new Item("Gold potion", 5, Bonus.HP, "&", Colors.Yellow, "Bottle with liquid.");
                default:
                    return new Item("Invisible", 0, Bonus.HP, ".", Colors.White);
            }
        }
    }
}